@extends('layouts.appManager')
@section('style')
    <style>
        .hide{display: none!important;}
    </style>
@endsection
@section('script')
    <script>
        let type='{{$server->type}}';
        var app = new Vue({
            el: '#app',
            data: {
                type:parseInt(type)
            }
        });
    </script>
@endsection
@section('content')
<div class="container py-5">
    <div class="row justify-content-center">
        <div class="col-md-8">
            <form method="POST" action="{{ route('server.update',['server'=>$server->id]) }}">
                @csrf
                {{ method_field('PUT') }}
                <div class="card panel">
                    <div class="card-header">基本信息配置</div>

                    <div class="card-body">

                            <div class="form-group row">
                                <label for="name" class="col-md-4 col-form-label text-md-right">服务器名称 <span class="text-danger">*</span></label>

                                <div class="col-md-6">
                                    <input id="name" type="text" class="form-control @error('name') is-invalid @enderror" name="name" value="{{ old('name')??$server->name }}" autocomplete="name" autofocus>

                                    @error('name')
                                        <span class="invalid-feedback" role="alert">
                                            <strong>{{ $message }}</strong>
                                        </span>
                                    @enderror
                                </div>
                            </div>

                            <div class="form-group row">
                                <label for="domain" class="col-md-4 col-form-label text-md-right">域名 <span class="text-danger">*</span></label>

                                <div class="col-md-6">
                                    <div class="input-group">
                                        <div class="input-group-prepend">
                                            <span class="input-group-text">http://</span>
                                        </div>
                                        <input id="domain" type="text" class="form-control @error('domain') is-invalid @enderror" name="domain" value="{{ old('domain')??$server->domain }}" autocomplete="domain" disabled>
                                        <div class="input-group-append">
                                            <span class="input-group-text" >.{{config('conf.domain')}}</span>
                                        </div>
                                        @error('domain')
                                        <span class="invalid-feedback" role="alert">
                                            <strong>{{ $message }}</strong>
                                        </span>
                                        @enderror
                                    </div>
                                </div>
                            </div>

                            <div class="form-group row">
                                <label for="info" class="col-md-4 col-form-label text-md-right">服务端介绍</label>

                                <div class="col-md-6">
                                    <textarea id="info" rows="5" class="form-control @error('info') is-invalid @enderror" name="info" autocomplete="info" placeholder="">{{ old('info')??$server->info }}</textarea>

                                    @error('info')
                                    <span class="invalid-feedback" role="alert">
                                            <strong>{{ $message }}</strong>
                                        </span>
                                    @enderror
                               </div>
                            </div>

                            {{--<div class="form-group row">
                                <label for="remark" class="col-md-4 col-form-label text-md-right">备注</label>

                                <div class="col-md-6">
                                    <input id="remark" type="text" class="form-control @error('remark') is-invalid @enderror" name="remark" value="{{ old('remark')??$server->remark }}" autocomplete="remark">

                                    @error('remark')
                                    <span class="invalid-feedback" role="alert">
                                            <strong>{{ $message }}</strong>
                                        </span>
                                    @enderror
                                </div>
                            </div>--}}

                            <div class="form-group row">
                                <label for="qq_group" class="col-md-4 col-form-label text-md-right">QQ群</label>

                                <div class="col-md-6">
                                    <input id="qq_group" type="text" class="form-control @error('qq_group') is-invalid @enderror" name="qq_group" value="{{ old('qq_group')??$server->qq_group }}" autocomplete="qq_group">

                                    @error('qq_group')
                                    <span class="invalid-feedback" role="alert">
                                            <strong>{{ $message }}</strong>
                                        </span>
                                    @enderror
                                </div>
                            </div>

                            <div class="form-group row">
                                <label for="qq_group" class="col-md-4 col-form-label text-md-right">客服QQ</label>

                                <div class="col-md-6">
                                    <input id="qq_server" type="text" class="form-control @error('qq_server') is-invalid @enderror" name="qq_server" value="{{ old('qq_server')??$server->qq_server }}" autocomplete="qq_server">

                                    @error('qq_server')
                                    <span class="invalid-feedback" role="alert">
                                            <strong>{{ $message }}</strong>
                                        </span>
                                    @enderror
                                </div>
                            </div>
                    </div>
                </div>

                <div class="card panel">
                    <div class="card-header">游戏服务配置</div>

                    <div class="card-body">

                        <div class="form-group row">
                            <label for="server_host" class="col-md-4 col-form-label text-md-right">服务器IP/域名 <span class="text-danger">*</span></label>

                            <div class="col-md-6">
                                <input id="server_host" type="text" class="form-control @error('server_host') is-invalid @enderror" name="server_host" value="{{ old('server_host')??$server->server_host }}" autocomplete="server_host">

                                @error('server_host')
                                <span class="invalid-feedback" role="alert">
                                        <strong>{{ $message }}</strong>
                                    </span>
                                @enderror
                            </div>
                        </div>

                        <div class="form-group row">
                            <label for="server_port" class="col-md-4 col-form-label text-md-right">世界服务端口 <span class="text-danger">*</span></label>

                            <div class="col-md-6">
                                <input id="server_port" type="number" class="form-control @error('server_port') is-invalid @enderror" name="server_port" value="{{ old('server_port')??$server->server_port }}" autocomplete="server_port">

                                @error('server_port')
                                <span class="invalid-feedback" role="alert">
                                        <strong>{{ $message }}</strong>
                                    </span>
                                @enderror
                            </div>
                        </div>

                        <div class="form-group row">
                            <label for="auth_port" class="col-md-4 col-form-label text-md-right">登录服务端口 <span class="text-danger">*</span></label>

                            <div class="col-md-6">
                                <input id="auth_port" type="number" class="form-control @error('auth_port') is-invalid @enderror" name="auth_port" value="{{ old('auth_port')??$server->auth_port }}" autocomplete="auth_port">

                                @error('auth_port')
                                <span class="invalid-feedback" role="alert">
                                        <strong>{{ $message }}</strong>
                                    </span>
                                @enderror
                            </div>
                        </div>

                    </div>
                </div>

                <div class="card panel">
                    <div class="card-header">通讯服务配置</div>

                    <div class="card-body">

                        <div class="form-group row">
                            <label for="server_host" class="col-md-4 col-form-label text-md-right">通讯服务IP/域名 <span class="text-danger">*</span></label>

                            <div class="col-md-6">
                                <input id="soap_host" type="text" class="form-control @error('soap_host') is-invalid @enderror" name="soap_host" value="{{ old('soap_host')??$server->soap_host }}" autocomplete="soap_host">

                                @error('soap_host')
                                <span class="invalid-feedback" role="alert">
                                        <strong>{{ $message }}</strong>
                                    </span>
                                @enderror
                            </div>
                        </div>

                        <div class="form-group row">
                            <label for="soap_port" class="col-md-4 col-form-label text-md-right">通讯端口 <span class="text-danger">*</span></label>

                            <div class="col-md-6">
                                <input id="soap_port" type="number" class="form-control @error('soap_port') is-invalid @enderror" name="soap_port" value="{{ old('soap_port')??$server->soap_port }}" autocomplete="soap_port">

                                @error('soap_port')
                                <span class="invalid-feedback" role="alert">
                                        <strong>{{ $message }}</strong>
                                    </span>
                                @enderror
                            </div>
                        </div>

                        <div class="form-group row">
                            <label for="soap_acc" class="col-md-4 col-form-label text-md-right">GM账户 <span class="text-danger">*</span></label>

                            <div class="col-md-6">
                                <input id="soap_acc" type="text" class="form-control @error('soap_acc') is-invalid @enderror" name="soap_acc" value="{{ old('soap_acc')??$server->soap_acc }}" autocomplete="soap_acc">

                                @error('soap_acc')
                                <span class="invalid-feedback" role="alert">
                                        <strong>{{ $message }}</strong>
                                    </span>
                                @enderror
                            </div>
                        </div>
                        <div class="form-group row">
                            <label for="soap_pwd" class="col-md-4 col-form-label text-md-right">GM密码 <span class="text-danger">*</span></label>

                            <div class="col-md-6">
                                <input id="soap_pwd" type="text" class="form-control @error('soap_pwd') is-invalid @enderror" name="soap_pwd" value="{{ old('soap_pwd')??$server->soap_pwd }}" autocomplete="soap_pwd">

                                @error('soap_pwd')
                                <span class="invalid-feedback" role="alert">
                                        <strong>{{ $message }}</strong>
                                    </span>
                                @enderror
                            </div>
                        </div>

                    </div>
                </div>

                <div class="card panel">
                    <div class="card-header">数据库配置</div>

                    <div class="card-body">

                        <div class="form-group row">
                            <label for="db_host" class="col-md-4 col-form-label text-md-right">数据库IP/域名 <span class="text-danger">*</span></label>

                            <div class="col-md-6">
                                <input id="db_host" type="text" class="form-control @error('db_host') is-invalid @enderror" name="db_host" value="{{ old('db_host')??$server->db_host }}" autocomplete="db_host">

                                @error('db_host')
                                <span class="invalid-feedback" role="alert">
                                        <strong>{{ $message }}</strong>
                                    </span>
                                @enderror
                            </div>
                        </div>

                        <div class="form-group row">
                            <label for="db_port" class="col-md-4 col-form-label text-md-right">数据库端口 <span class="text-danger">*</span></label>

                            <div class="col-md-6">
                                <input id="db_port" type="number" class="form-control @error('db_port') is-invalid @enderror" name="db_port" value="{{ old('db_port')??$server->db_port }}" autocomplete="db_port">

                                @error('db_port')
                                <span class="invalid-feedback" role="alert">
                                        <strong>{{ $message }}</strong>
                                    </span>
                                @enderror
                            </div>
                        </div>

                        <div class="form-group row">
                            <label for="db_acc" class="col-md-4 col-form-label text-md-right">数据库账户 <span class="text-danger">*</span></label>

                            <div class="col-md-6">
                                <input id="db_acc" type="text" class="form-control @error('db_acc') is-invalid @enderror" name="db_acc" value="{{ old('db_acc')??$server->db_acc }}" autocomplete="db_acc">

                                @error('db_acc')
                                <span class="invalid-feedback" role="alert">
                                        <strong>{{ $message }}</strong>
                                    </span>
                                @enderror
                            </div>
                        </div>
                        <div class="form-group row">
                            <label for="db_pwd" class="col-md-4 col-form-label text-md-right">数据库密码 <span class="text-danger">*</span></label>

                            <div class="col-md-6">
                                <input id="db_pwd" type="text" class="form-control @error('db_pwd') is-invalid @enderror" name="db_pwd" value="{{ old('db_pwd')??$server->db_pwd }}" autocomplete="db_pwd">

                                @error('db_pwd')
                                <span class="invalid-feedback" role="alert">
                                        <strong>{{ $message }}</strong>
                                    </span>
                                @enderror
                            </div>
                        </div>

                    </div>
                </div>

                {{--<div class="card panel {{$server->type==2?'hide':''}}">
                    <div class="card-header">服务器类型</div>

                    <div class="card-body">
                        <div class="form-group row">
                            <label for="root_pwd" class="col-md-4 col-form-label text-md-right">服务器类型 <span class="text-danger">*</span></label>

                            <div class="col-md-6">
                                <select v-model="type" class="form-control" name="type">
                                    <option :value="2">Linux</option>
                                    <option :value="1">Windows</option>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>--}}

                <div class="card panel" v-if="type===2">
                    <div class="card-header">Linux服务器配置</div>

                    <div class="card-body">

                        <div class="form-group row">
                            <label for="root_pwd" class="col-md-4 col-form-label text-md-right">root账号密码 <span class="text-danger">*</span></label>

                            <div class="col-md-6">
                                <input id="root_pwd" type="text" class="form-control @error('root_pwd') is-invalid @enderror" name="root_pwd" value="{{ old('root_pwd')??$server->root_pwd }}" autocomplete="root_pwd" maxlength="35">

                                @error('root_pwd')
                                <span class="invalid-feedback" role="alert">
                                    <strong>{{ $message }}</strong>
                                </span>
                                @enderror
                            </div>
                        </div>

                    </div>
                </div>



                <div class="card panel" v-if="type===1">
                    <div class="card-header">Windows宝塔API配置</div>

                    <div class="card-body">

                        <div class="form-group row">
                            <label for="bt_url" class="col-md-4 col-form-label text-md-right">API地址 <span class="text-danger">*</span></label>

                            <div class="col-md-6">
                                <input id="bt_url" type="text" class="form-control @error('bt_url') is-invalid @enderror" name="bt_url" value="{{ old('bt_url')??$server->bt_url }}" autocomplete="bt_url" maxlength="100">

                                @error('bt_url')
                                <span class="invalid-feedback" role="alert">
                                    <strong>{{ $message }}</strong>
                                </span>
                                @enderror
                            </div>
                        </div>

                        <div class="form-group row">
                            <label for="bt_key" class="col-md-4 col-form-label text-md-right">密钥 <span class="text-danger">*</span></label>

                            <div class="col-md-6">
                                <input id="bt_key" type="text" class="form-control @error('bt_key') is-invalid @enderror" name="bt_key" value="{{ old('bt_key')??$server->bt_key }}" autocomplete="bt_key" maxlength="35">

                                @error('bt_key')
                                <span class="invalid-feedback" role="alert">
                                    <strong>{{ $message }}</strong>
                                </span>
                                @enderror
                            </div>
                        </div>

                        {{--<div class="form-group row">
                            <label for="path" class="col-md-4 col-form-label text-md-right">服务端路径</label>

                            <div class="col-md-6">
                                <input id="path" type="text" class="form-control @error('path') is-invalid @enderror" name="path" value="{{ old('path')??$server->path }}" autocomplete="path" maxlength="100">

                                @error('path')
                                <span class="invalid-feedback" role="alert">
                                    <strong>{{ $message }}</strong>
                                </span>
                                @enderror
                            </div>
                        </div>--}}

                        <div class="form-group row">
                            <label for="luaPath" class="col-md-4 col-form-label text-md-right">worldserver.conf路径</label>

                            <div class="col-md-6">
                                <input id="configPath" type="text" class="form-control @error('configPath') is-invalid @enderror" name="configPath" value="{{ old('configPath')??$server->configPath }}" autocomplete="configPath" maxlength="50">

                                @error('configPath')
                                <span class="invalid-feedback" role="alert">
                                    <strong>{{ $message }}</strong>
                                </span>
                                @enderror


                            </div>
                        </div>

                        <div class="form-group row">
                            <label for="configPath" class="col-md-4 col-form-label text-md-right">lua_scripts目录</label>

                            <div class="col-md-6">
                                <input id="luaPath" type="text" class="form-control @error('luaPath') is-invalid @enderror" name="luaPath" value="{{ old('luaPath')??$server->luaPath }}" autocomplete="luaPath" maxlength="50">

                                @error('luaPath')
                                <span class="invalid-feedback" role="alert">
                                    <strong>{{ $message }}</strong>
                                </span>
                                @enderror


                            </div>
                        </div>

                    </div>
                </div>




                <div class="col-md-6 offset-md-3">
                    <button type="submit" class="btn btn-primary btn-block">
                        提交
                    </button>
                </div>
            </form>
        </div>
    </div>
</div>
@endsection
